import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/utils/module_permissions_util.dart';
import 'package:enterprise_v6_app/app/data/entities/application/securtity_base_drawer.dart';
import 'package:enterprise_v6_app/app/modules/application/education/course_center/course_center_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/demand_research/all_research_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/home/home_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/home/model.dart';
import 'package:enterprise_v6_app/app/modules/application/education/teacher_power/teacher_power_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/train_program_view.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';

class EducationModController extends GetxController {
  /// scaffoldKey
  final scaffoldKey = GlobalKey<ScaffoldState>();
  /// 筛选右侧栏控制Key
  final riskRightScaffoldKey = GlobalKey<ScaffoldState>();

  /// 选中的页面
  int selectIndex = 0;
  var filterWidget = Rx<Widget>(Container());
  final titleList = [
    SecurityBaseEntity(
        title: '总览',
        icon: AppImages.icon_eduction_list,
        expandTitle: '总览',
        currentPageTitle: 0,
        pageTitle: ['个人统计', '全厂统计'],
        pages: [
          EducationHomeView(type: EducationHomeSummaryType.personal),
          EducationHomeView(type: EducationHomeSummaryType.whole),
        ],
        path: '/home'),
    SecurityBaseEntity(
        title: '师资力量',
        icon: AppImages.icon_education_teacher_power,
        expandTitle: '师资力量',
        currentPageTitle: 0,
        pages: [TeacherPowerView()],
        path: '/teacherPower'),
    SecurityBaseEntity(
        title: '课程中心',
        icon: AppImages.icon_education_course_center,
        expandTitle: '课程中心',
        currentPageTitle: 0,
        pages: [CourseCenterView()],
        path: '/courseCenter'),
    SecurityBaseEntity(
        title: '需求调研',
        icon: AppImages.icon_education_demand_research,
        expandTitle: '所有调研',
        currentPageTitle: 0,
        pages: [
          AllResearchPage(),
        ],
        path: '/demandResearch'),
    SecurityBaseEntity(
      title: '培训计划',
      icon: AppImages.icon_education_train_plan,
      expandTitle: '培训计划',
      currentPageTitle: 0,
      pages: [TrainProgramView()],
      path: '/trainPlan',
    ),
    // SecurityBaseEntity(
    //     title: '个人档案',
    //     icon: AppImages.icon_education_personal_profile,
    //     expandTitle: '个人档案',
    //     currentPageTitle: 0,
    //     pages: [EducationProfileAssessmentView()],
    //     path: '/personalProfile'),
  ];

  @override
  void onInit() {
    super.onInit();
    initModule();
  }

  /// 根据后台权限初始化菜单
  void initModule() {
    ModulePermissionsUtil.removeRoleMenu(titleList: titleList, routes: AppRoutes.educationTraining);
    update();
  }

  /// title选择切换
  /// [titleIndex] 标题索引
  /// [index] 页面索引
  void selectTitle(int titleIndex, int index) {
    titleList[titleIndex].currentPageTitle = index;
    update();
  }

  /// 点击左侧菜单
  /// [index] 索引
  void selectLeftMenu(int index) {
    selectIndex = index;
    update();
  }

  /// 点击展开菜单
  /// [index] 索引
  void selectExpandMenu(int index) {
    selectIndex = index;
    Get.back();
    update();
  }
}
